#ifndef COOLPOOL_SIMULATION_COLLISION_H_
#define COOLPOOL_SIMULATION_COLLISION_H_

#include <Vector3D.h>

#include "DynamicEntity.h"

namespace coolpool
{
	// There are three types of collisons:
	// RESTING_CONTACT - the collision will be threated specially,
    //                   by adding repulsion force to the object.
	// INTERPENETRATION - classic collision
	// MOVINGAWAY - means that the objects are moving away from each other, probably beceause
	//              the collision was handled in previous frame.
	enum CollisionType
	{
		RESTING_CONTACT, INTERPENETRATION, MOVINGAWAY
	};

	// Container for collision information which are needed
	// for the collision handling from the collision detection engine.
	struct Collision
	{
	public:
		// Time of the collision in current time step.
		double time;

		// First element of collision (at least one of them must be dynamic)
		DynamicEntity * first;

		// Second element of collision
		Entity * second;

		// Point of collision.
		math_tools::Vector3D collision_point;

		// Collision normal.
		math_tools::Vector3D collision_normal;

		// Collision type.
		CollisionType type;

		// Operators overloading:
		bool operator==(const Collision & col) const
		{
			return time == col.time;
		}
		bool operator<(const Collision & col) const
		{
			return time < col.time;
		}
		bool operator<=(const Collision & col) const
		{
			return (*this < col) && (*this == col);
		}
	};
}

#endif
